package landian.com.module_base.utils;

import android.content.Context;
import android.widget.Toast;

/**
 * Created by Administrator on 2019-03-04.
 */

public class ToastUtil {
    private static Toast mToast;

    private static void showToast(Context context, String msg, int duration) {
        if (context == null) {
            return;
        }
        if (mToast == null) {
            mToast = Toast.makeText(context, msg, duration);
        } else {
            mToast.setText(msg);
            mToast.setDuration(duration);
        }
        mToast.show();
    }

    public static void showLongToast(Context context, String msg) {
        ToastUtil.showToast(context, msg, Toast.LENGTH_LONG);
    }

    public static void showLongToast(Context context, int msgId) {
        ToastUtil.showToast(context, context.getString(msgId), Toast.LENGTH_LONG);
    }
}
